package com.example.sound;


import android.app.Activity;
import android.view.View.OnClickListener;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.media.ToneGenerator;

public class sound extends Activity implements OnClickListener{
    private ToneGenerator mtoneGenerator;


        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mtoneGenerator = new ToneGenerator(ToneGenerator.TONE_DTMF_1, 100);
            
        Button playbtn = (Button) findViewById(R.id.play);
        playbtn.setOnClickListener(this);
        
        Button tonebtn = (Button) findViewById(R.id.tone);
        tonebtn.setOnClickListener(this);
        
        Button stopbtn = (Button) findViewById(R.id.stop);
        stopbtn.setOnClickListener(this);
        
        Button stop2btn = (Button) findViewById(R.id.stop2);
        stop2btn.setOnClickListener(this);
    }


        public void onClick(View view) {
        
        MediaPlayer mp = MediaPlayer.create(this, R.raw.test);

       if (view == findViewById(R.id.play)) {
           mp.start();                   
       }
       if (view == findViewById(R.id.tone)) {

           mtoneGenerator.startTone(ToneGenerator.TONE_DTMF_1);

       }
       if (view == findViewById(R.id.stop)) {
           mtoneGenerator.stopTone();

       }
       if (view == findViewById(R.id.stop2)) {
           mp.stop();
       }
       
    }
    
}
